﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Eatime.Entitys
{
    public class Item : INotifyPropertyChanged
    {
        private string _title;
        public string Title
        {
            get { return _title; }
            set
            {
                if (value != _title)
                {
                    _title = value;
                    NotifyPropertyChanged("Title");
                }
            }
        }

        private string _nick;
        /// <summary>
        /// 卖家昵称
        /// </summary>
        public string Nick
        {
            get { return _nick; }
            set
            {
                if (value != _nick)
                {
                    _nick = value;
                    NotifyPropertyChanged("Nick");
                }
            }
        }

        private string _desc;
        /// <summary>
        /// 商品描述, 字数要大于5个字符，小于25000个字符
        /// </summary>
        public String Desc
        {
            get { return _desc; }
            set
            {
                if (value != _desc)
                {
                    _desc = value; NotifyPropertyChanged("Desc");
                }
            }
        }

        private DateTime _created = DateTime.Now;
        public DateTime Created
        {
            get
            {
                return _created;
            }
            set
            {
                if (value != _created)
                {
                    _created = value;
                    NotifyPropertyChanged("Created");
                }
            }
        }

        private DateTime _modified = DateTime.Now;
        /// <summary>
        /// 商品修改时间
        /// </summary>
        public DateTime Modified
        {
            get { return _modified; }
            set
            {
                if (value != _modified)
                {
                    _modified = value;
                    NotifyPropertyChanged("Modified");
                }
            }
        }

        private decimal _price = 0M;
        /// <summary>
        /// 商品价格，格式：5.00；单位：元；精确到：分
        /// </summary>
        public decimal Price
        {
            get { return _price; }
            set
            {
                if (value != _price)
                {
                    _price = value;
                    NotifyPropertyChanged("Price");
                }
            }
        }

        private int _shopId = 0;
        public int ShopId
        {
            get { return _shopId; }
            set
            {
                if (value != _shopId)
                {
                    _shopId = value;
                    NotifyPropertyChanged("ShopId");
                }
            }
        }

        private string _deviceUniqueId;
        public string DeviceUniqueId
        {
            get { return _deviceUniqueId; }
            set
            {
                if (value != _deviceUniqueId)
                {
                    _deviceUniqueId = value;
                    NotifyPropertyChanged("DeviceUniqueId");
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
    }
}
